package pers.yurwisher.rubick.manager.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.yurwisher.rubick.common.base.BaseController;
import pers.yurwisher.rubick.common.wrapper.R;
import pers.yurwisher.rubick.manager.pojo.fo.SystemButtonFo;
import pers.yurwisher.rubick.manager.service.ISystemButtonService;

/**
 * @author yq
 * @date 2020-09-26 11:35:17
 * @description 按钮
 * @since V1.0.0
 */
@RestController
@RequestMapping("/button")
@RequiredArgsConstructor
public class SystemButtonController extends BaseController {
    private final ISystemButtonService systemButtonService;

    @PostMapping
    public R create(@RequestBody @Validated SystemButtonFo fo) {
        systemButtonService.create(fo);
        return R.ok();
    }

    @PostMapping("{id}")
    public R update(@PathVariable(name = "id") Long id, @RequestBody @Validated SystemButtonFo fo) {
        systemButtonService.update(id, fo);
        return R.ok();
    }

    @GetMapping("{id}")
    public R get(@PathVariable(name = "id") Long id) {
        return R.ok(systemButtonService.getById(id));
    }


}
